
COREUTILS = coreutils-6.9

all: reflink

reflink: $(COREUTILS)/src/reflink

$(COREUTILS)/Makefile: $(COREUTILS)/Makefile.in $(COREUTILS)/configure
	./configure

$(COREUTILS)/lib/libcoreutils.a: $(COREUTILS)/Makefile
	$(MAKE) -C $(COREUTILS)/lib

$(COREUTILS)/src/ln: $(COREUTILS)/lib/libcoreutils.a $(COREUTILS)/src/ln.c
	$(MAKE) -C $(COREUTILS)/src ln

$(COREUTILS)/src/reflink: $(COREUTILS)/src/ln
	ln -f $^ $@

clean:
	$(MAKE) -C $(COREUTILS) clean

distclean: clean
	$(MAKE) -C $(COREUTILS) distclean

dist:
	git archive --format=tar --prefix=reflink-0.1.0/ HEAD | \
		gzip -c >reflink-0.1.0.tar.gz

install: reflink
	$(MAKE) -C coreutils-6.9/src/ bin_PROGRAMS=reflink install-binPROGRAMS

.PHONY: reflink install distclean clean all
